// NightShader.java - 基于BaseShader创建夜间效果
package com.goldsprite.gameframeworks.shaders;

import com.badlogic.gdx.Gdx;
import com.goldsprite.gameframeworks.ecs.system.GameSystem;
import com.goldsprite.gameframeworks.log.Debug;
import com.goldsprite.gameframeworks.utils.TimeUtils;
import com.goldsprite.gameframeworks.utils.math.Vector2;

public class LightShader extends BaseShader {
	private int uViewSizeLocation;
	private int uLightPosition2dLocation;
    public LightShader() {
        super("shaders/light.vert", "shaders/light.frag");
    }

    @Override
    protected void initUniforms() {
		uViewSizeLocation = shaderProgram.getUniformLocation("u_viewSize");
		uLightPosition2dLocation = shaderProgram.getUniformLocation("u_lightPosition2d");
    }

	public Vector2 lightPos = new Vector2();
	Vector2 norLightPos = new Vector2();
    @Override
    public void setUniforms() {
		float viewWidth = GameSystem.uiViewport.getWorldWidth();
		float viewHeight = GameSystem.uiViewport.getWorldHeight();

		shaderProgram.setUniformf(uViewSizeLocation, viewWidth, viewHeight);

		norLightPos.set(lightPos).div(viewWidth,  viewHeight);
		shaderProgram.setUniformf(uLightPosition2dLocation, norLightPos.x, norLightPos.y);
    }

	@Override
	public void update(float delta) {
		super.update(delta);
	}
}
